package com.aaa.java08;

import sun.applet.Main;

import java.time.LocalDate;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/11 14:35
 * @description：人类
 * @modified By：
 * @version: 1.0
 */
public class Person {
    //public int  id;
  //  protected int  id;
    // int  id;
    private  int  id;
    private  String name;
    private LocalDate birthday;
    private boolean sex;



    public Person() {
    }

    public Person(int id, String name, LocalDate birthday) {
        this.id = id;
        this.name = name;
        this.birthday = birthday;
    }

    /**
     * 读取属性值
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * 设置属性值
     * @param name
     */
    public void setName(String name) {
        //此处可以校验数据的合法性
        System.out.println("类似派出所户籍室");
        this.name = name;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        //判断生日的合法性
       if(birthday.isAfter(LocalDate.now())) {
            System.out.println("生日非法");
           this.birthday=LocalDate.now();
       }else
       {
           this.birthday = birthday;
       }

    }
    //sex的set方法
/*    public  void setSex(boolean sex){
        this.sex=sex;
    }
    public boolean getSex(){
        return sex;
    }*/
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: boolean类型的get方法特殊，is开始
     * @create time: 2022/7/11 15:20
     * @return
     */
    public boolean isSex() {
        return sex;
    }

    public void setSex(boolean sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", birthday=" + birthday +
                '}';
    }

    public static void main(String[] args) {
        Person person = new Person();
        person.id=12;
    }

}
